<?php
    $buffer='<?xml version="1.0" encoding="utf-8"?>'
        .'<Query NAME="'.$_POST['query'].'" LEN="1" NP="'.($_POST['inputs']+$_POST['outputs']).'">'
           .'<Inputs NUM="'.$_POST['inputs'].'">';
            for($i = 1; $i <= $_POST['inputs']; $i++) {
                $buffer = $buffer.'<Input NUM="'.$i.'" TYPE="'.$_POST["inurl_".($i-1)].'">';
                for($j = 0; $j <= $_POST['inputs'.($i-1)]; $j++) {
                    $buffer = $buffer.'<Value VAL="'.$_POST['inputs'.($i-1).'-'.$j].'" />';
                }
                $buffer = $buffer.'</Input>';
            }
            $buffer = $buffer.'</Inputs>'
            .'<Outputs NUM="'.$_POST['outputs'].'">';
            for($i = 0; $i < $_POST['outputs']; $i++) {
                $buffer = $buffer.'<Output NUM="'.$i.'" TYPE="'.$_POST['output'.$i].'"/>';
            }
            $buffer = $buffer.'</Outputs></Query>';
     
     $name_file="query.xml";
     $file=fopen($name_file,"w+");
     fwrite ($file,$buffer);
     fclose($file);
    
     simplexml_load_file('query.xml');   // Se crea un archivo 'query.xml' con el query
    
     header( "Status: 301 Moved Permanently", false, 301);
     header("Location: /callComposer.php");
     exit();  
?> 